<?php
header('Content-Type:text/html;charset=utf-8');
$account=$_POST['account'];
$pwd=$_POST['pwd'];
$pwd1=$_POST['pwd1'];
$pname=$_POST['pname'];
$email=$_POST['email'];
$yzm=$_POST['yzm'];
$cyzm=$_COOKIE['yzm'];
require_once($_SERVER['DOCUMENT_ROOT'].'/public/func.php');
$config=require_once($_SERVER['DOCUMENT_ROOT'].'/public/config.php');
$acarr=selects($config,'vip',"where `account`='$account'")[0];
$arrpn=selects($config,'vip',"where `pname`='$pname'&&`account`='$account'");
$arrem=selects($config,'vip',"where `email`='$email'&&`account`='$account'&&`pname`='$pname'&&`email`='$email'");
$arr=selects($config,'vip',"where `account`='$account'&&`pname`='$pname'&&`email`='$email'");
$arrxiu=array('pwd'=>$_POST['pwd']);
if(!strcasecmp($yzm,$cyzm)=='0'){
    echo "<script>alert('验证码输入错误');window.location.href='/home/landing/forgetland/index.php'</script>";
}else{
    setcookie('yzm','');
}
if(!$acarr){
    echo "<script>alert('该账户不存在');window.location.href='/home/landing/forgetland/index.php'</script>";
}elseif(!$arrpn){
    echo "<script>alert('该昵称不正确');window.location.href='/home/landing/forgetland/index.php'</script>";
}elseif(!$arrem){
    echo "<script>alert('该注册邮箱不正确');window.location.href='/home/landing/forgetland/index.php'</script>";
}elseif(!$pwd){
    echo "<script>alert('新密码不能为空');window.location.href='/home/landing/forgetland/index.php'</script>";
}elseif($pwd!=$pwd1){
    echo "<script>alert('两次输入密码不一致');window.location.href='/home/landing/forgetland/index.php'</script>";
}elseif(!$arr){
    echo "<script>alert('信息输入错误');window.location.href='/home/landing/forgetland/index.php'</script>";
}else{
   $rec=xiugai($config,'vip',"where `id`={$acarr['id']}",$arrxiu);

   if($rec){
    echo "<script>alert('修改密码成功');window.location.href='/home/landing/index.php'</script>";
   }else{
     echo "<script>alert('修改密码失败');window.location.href='/home/landing/forgetland/index.php'</script>";
   }
}
?>